<template>
  <div>
    <el-dropdown trigger="click" @command="handleSetSize">
      <div class="size-icon--style">
        <svg-icon class-name="size-icon" color="#fff" icon-class="size" />
      </div>
      <template #dropdown>
        <el-dropdown-menu>
          <el-dropdown-item v-for="item of sizeOptions" :key="item.value" :disabled="size === item.value" :command="item.value">
            {{ item.label }}
          </el-dropdown-item>
        </el-dropdown-menu>
      </template>
    </el-dropdown>
  </div>
</template>


<script setup>
import SvgIcon from "@/components/GUI/SvgIcon.vue"
import modal from "@/plugins/modal.js"
import store from '@/store/index.js'

const appStore = store.app
const size = computed(() => appStore.size)
const sizeOptions = ref([
  {label: "较大", value: "large"},
  {label: "默认", value: "default"},
  {label: "稍小", value: "small"},
])

function handleSetSize(size) {
  appStore.size = size
  appStore.setSize(size)
  modal.msgSuccess("布局大小设置成功！")
}

</script>

<style lang="scss" scoped>
.size-icon--style {
  font-size: 18px;
  line-height: 50px;
}
</style>
